$(function(){
        $("#form-app-update").validate({
        rules:{
            name:{
                required:true
            },
            code:{
                required:true
            },
            sortNum:{
                required:true
            }
        },
        messages: {
        	name: "请输入应用名称",
        	code: "请输入应用编码",
        	sortNum : "请输入应用排序"
        },
        onkeyup:false,
        focusCleanup:true,
        success:"",
        submitHandler:function(form){
            var options = {
                type: $(form).attr("method"),
                url: $(form).attr("action"),
                success : formResponse,
                dataType: 'json',  
                error : function(xhr, status, err) {
                }  
            };   
            $(form).ajaxSubmit(options);
        }
    });
});


/*表单回调函数*/
function formResponse(responseText, statusText){
    if(responseText.code == 200){
        layer.msg("更新成功,2秒后自动关闭窗口", {
            shift: 2,
            time : 2000,
            icon: 6
        },function(){
            //关闭弹出框
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        
        $("#searchBtn", parent.document).click();
    }else{
        layer.msg(responseText.msg, {
            shift: 2,
            icon: 5
        });
        return false;
    }
}
